package cn.wolfcode.p2p.business.service.impl;

import cn.wolfcode.p2p.base.domain.LoginInfo;
import cn.wolfcode.p2p.business.domain.ExpAccount;
import cn.wolfcode.p2p.business.mapper.ExpAccountMapper;
import cn.wolfcode.p2p.business.service.IExpAccountService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.math.BigDecimal;

@Service
@Transactional
public class ExpAccountServiceImpl implements IExpAccountService {

    @Autowired
    private ExpAccountMapper expAccountMapper;


    @Override
    public ExpAccount getById(Long id) {
        return expAccountMapper.selectByPrimaryKey(id);
    }

    @Override
    public void init(LoginInfo info) {
        //发放体验金1000元
        ExpAccount expAccount = new ExpAccount();
        expAccount.setId(info.getId());
        expAccount.setUsableAmount(new BigDecimal(1000));
        expAccountMapper.insert(expAccount);

    }
}
